<script>
	import Vue from 'vue'
		export default {
			globalData: {
				baseURL: 'http://localhost:9091'
			},
			onLaunch: function() {
				uni.getSystemInfo({
					success: function(e) {
						console.log(e)
						Vue.prototype.screenWidth = e.screenWidth
						// #ifndef MP
						Vue.prototype.StatusBar = e.statusBarHeight;
						if (e.platform == 'android') {
							Vue.prototype.CustomBar = e.statusBarHeight + 50;
						} else {
							Vue.prototype.CustomBar = e.statusBarHeight + 45;
						};
						// #endif
						// #ifdef MP-WEIXIN
						Vue.prototype.StatusBar = e.statusBarHeight;
						let custom = wx.getMenuButtonBoundingClientRect();
						Vue.prototype.Custom = custom;
						Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
						// #endif       
						// #ifdef MP-ALIPAY
						Vue.prototype.StatusBar = e.statusBarHeight;
						Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
						// #endif
					}
				})
			},
			onShow: function() {
				//第一次进入本界面时都会更新最新数据（访问数据库）
				try {
				    const Auth = uni.getStorageSync('Auth');
				    if (Auth.isLogin) {
						uni.showLoading({})
						uniCloud.callFunction({
							name: 'selectUser',
							data: {
								phone: Auth.phone
							}
						}).then((res) => {
							this.user = res.result.data[0]
							this.isLogin=true
							this.progressWidth = this.user.grow+"%"
							this.isShowCard=true
							this.$store.commit("user/setUser", this.user)
							uni.hideLoading()
						}).catch((err) => {
							uni.hideLoading()
							uni.showModal({
								content: `操作失败：${err.message}`,
								showCancel: false
							})
						})
				    }
					else{
						this.isLogin=false
					}
				} catch (e) {
					uni.showToast({
						title:"数据异常，请重试~",
						duration:1500
					})
				}
				console.log('App Show')
			},
			onHide: function() {
				console.log('App Hide')
			}
		}
	</script>
	
	<style lang="scss">
		/* color-ui库 */
		@import "colorui/main.css";
		@import "colorui/icon.css";
		@import "colorui/animation.css";
	
		/*每个页面公共css */
		page {
			background-color: #FFFFFF;
			overflow-x: hidden;
			
		}
	
		.Messange-box {
			position: fixed;
			right: 0;
			top: 50%;
			background: #272822;
			width: 30px;
			height: 50px;
			z-index: 99999;
		}
	</style>
